﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>版本列表</title>
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script language="JavaScript" src="../../Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/layui/layui/layui.js" type="text/javascript"></script>
    <script src="../../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
    <style type="text/css">
        .layui-table-cell .layui-form-checkbox[lay-skin=primary]{
            top:0px !important;
        }
    </style>
    <script type="text/javascript">
        var dbvars = null;
        $(function () {

            var frmID = GetQueryString("FrmID");
            var oid = GetQueryString("OID");
			if(oid == null)
                oid = GetQueryString("WorkID");

            dbvars = new Entities("BP.Sys.FrmDBVers");
            dbvars = dbvars.DoMethodReturnJSON("ChapterFrmDBVers", frmID, oid);
            layui.table.render({
                elem: '#tableID',
                cellMinWidth: 80,
                cols: [[
                    { type: 'checkbox', align: 'center' }
                    , { field: 'MyPK', title: 'MyPK', hide: true, align: 'center' }
                    , {
                        field: 'Ver', title: '版本号', align: 'center',
                        templet: function (row) {
                            return "Ver" + row["Ver"] + ".0";
                        }
                    }

                    , { field: 'RDT', title: '日期', }
                    , { field: 'RecName', title: '编辑者', }
                    //, {
                    //    field: '_operate', title: '操作',
                    //    templet: function (row) {
                    //        return "<a class='layui-btn  layui-btn-xs' lay-event='OpenFrm'>打开表单</a>";
                    //    }
                    //}

                ]],
                data: dbvars,
                text: {
                    none: '暂无数据,不需要版本比对'
                }
            });
            layui.table.on('tool(tableID)', function (obj) {
                var data = obj.data;
                if (obj.event === 'OpenFrm') {
                    var width = window.innerWidth*3/5;
                    var url = "../../MyFrm.htm?WorkID=" + oid + "&FK_Flow=" + GetQueryString("FK_Flow") + "&FK_Node=" + GetQueryString("FK_Node");
                    OpenLayuiDialog(url, "表单信息", width, 100, 'r', false);
                } 
            });
            $("#Btn_Compare").on("click",function () {
                //选择的版本是不是两个，
                var checkedItems = layui.table.checkStatus('tableID');
                if (checkedItems.data.length!=2) {
                    layer.alert("只能选择两个表单数据版本进行比对");
                    return;
                }
                var ver1 = checkedItems.data[0].Ver;
                var ver2 = checkedItems.data[1].Ver;
                var url = "./DBVer.htm?FrmID=" + frmID + "&OID=" + oid + "&MainVer=" + ver1 + "&CompareVer=" + ver2;
                OpenFullLayuiDialog(url, "版本比对");
            });
            if (dbvars < 2) {
                if (dbvars.length == 1)
                    $("#shuoming").html("当前表单只存在一个数据版本,不需要比对");
                $("#Btn_Compare").attr("disabled", "true");
            }
            
        });
    
    </script>
</head>
<body>
    <div class="layui-container" style="margin-top:20px">
        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="Btn_Compare">版本比对</button>
        <table class="layui-table" id="tableID" lay-filter="tableID"></table>
        <label class="layui-menu-body-title" id="shuoming"></label>
    </div>
</body>
</html>
